/*------------------------------------------------------------------------
 Module:		mytypes.h
 Author:		solar
 Project:		 
 Creation Date: 2008-10-29
 Description:	
------------------------------------------------------------------------*/

#ifndef _MYTYPES_H
#define _MYTYPES_H

#ifdef __cplusplus
extern "C" {
#endif

#if	!defined(EOF) || (EOF!=(-1))
#define EOF		(-1)
#endif

#if	!defined(EOS) || (EOS!='\0')
#define EOS		'\0'	
#endif

#if	!defined(FALSE) || (FALSE!=0)
#define FALSE		0
#endif

#if	!defined(TRUE) || (TRUE!=1)
#define TRUE		1
#endif

#if	!defined(false) || (false!=0)
#define false		0
#endif

#if	!defined(true) || (true!=1)
#define true		1
#endif

typedef struct{
		unsigned char mtsl;
		unsigned char mtsh;
		unsigned char exps;
}trifloat;

typedef union
{
	int iData;
	float fData;
}UNION_MUT_CONV;

typedef unsigned char		BYTE;
typedef unsigned short		WORD;
typedef unsigned long		DWORD;

typedef unsigned char		uint8_t;
typedef unsigned short		uint16_t;
typedef unsigned long		uint32_t;
typedef unsigned long long	uint64_t;

typedef signed char			int8_t;
typedef signed short		int16_t;
typedef signed long			int32_t;
typedef signed long long	int64_t;


#ifdef __cplusplus
typedef void (*ENTRYPTR)(...);			/* ptr to function returning void */
#else
typedef void (*ENTRYPTR) ();			/* ptr to function returning void */
#endif			/* _cplusplus */

#if (TYPE_OS == OS_VXWORKS)
typedef unsigned char		uint8;
typedef unsigned short		uint16;
typedef unsigned long		uint32;

typedef signed char			int8;
typedef signed short		int16;
typedef signed long			int32;
#endif

#define OK					1

#define WAIT_FOREVER		-1
#define FAST				register
#define IMPORT				extern
#define LOCAL				static
typedef int					STATUS;
#define myinline			static __inline


#define LOBYTE(w)			((BYTE)(w))
#define HIBYTE(w)			((BYTE)((WORD)(w) >> 8))
#define LOWORD(l)			((WORD)(l))
#define HIWORD(l)			((WORD)((DWORD)(l) >> 16))
#define MAKEWORD(low,high)	((WORD)((BYTE)(low)|(((WORD)((BYTE)(high)))<< 8)))				//半字合并，两个8位数据合成一个16位半字数据
#define MAKEDWORD(low,high)	((DWORD)(((WORD)(low))|(((DWORD)((WORD)(high)))<< 16)))     //字合并，两个16位数据合成一个32位字数据
#define ADJUSTWORD(x)		(MAKEWORD(HIBYTE(x),LOBYTE(x)))
#define ADJUSTDWORD(x)		(MAKEDWORD(ADJUSTWORD(HIWORD(x)),ADJUSTWORD(LOWORD(x))))
#define BYTE2BCD(v)			((((BYTE)v/10)<<4)|((BYTE)v%10))
#define BCD2BYTE(v)			(((BYTE)v>>4)*10+((BYTE)v&0x0F))
#define WORD2BCD(v)			((BYTE2BCD((WORD)v/100)<<8) | (BYTE2BCD((WORD)v%100)))
#define BCD2WORD(v)			(BCD2BYTE((WORD)v>>8) *100 + BCD2BYTE((WORD)v&0xFF))
#define DWORD2BCD(v)		(WORD2BCD((DWORD)v/10000)<<16) | (WORD2BCD((DWORD)v%10000)))
#define BCD2DWORD(v)		(BCD2WORD((DWORD)v>>16) *10000 + BCD2WORD((DWORD)v&0xFFFF))

#ifdef __cplusplus
}
#endif


#endif /*_MYTYPES_H*/
